import { RouteRecordRaw } from 'vue-router'
import { defineAsyncComponent } from 'vue'

const routes: Array<RouteRecordRaw> = [
  {
    path: '/',
    meta: {},
    redirect: {
      name: 'Dashboard'
    }
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import('@/views/Main/login.vue'),
    meta: {
      title: '登录'
    },
  },
  {
    path: '/dashboard',
    name: 'Dashboard',
    component: () => import('@/views/Dashboard/dashboard.vue'),
    redirect: '/home',
    meta: {
      title: '主页'
      // meta用于提供一些路由用到的配置，例如这是页面名称、页面是否需要鉴权
    },
    children: [
      {
        path: '/home',
        name: 'Home',
        component: () => import('@/views/Home/home.vue'),
        meta: {
          title: '首页看板',
        }
      },
      {
        path: '/user-manage',
        name: 'UserManage',
        component: () => import('@/views/UserManage/user-manage.vue'),
        meta: {
          title: '用户管理',
        }
      },
      {
        path: '/project-manage',
        name: 'ProjectManage',
        component: () => import('@/views/ProjectManage/project-manage.vue'),
        meta: {
          title: '项目管理',
        }
      },
      {
        path: '/product-manage',
        name: 'ProductManage',
        component: () => import('@/views/ProductManage/product-manage.vue'),
        meta: {
          title: '产品管理',
        }
      },
      {
        path: '/device-manage',
        name: 'DeviceManage',
        component: () => import('@/views/DeviceManage/device-manage.vue'),
        meta: {
          title: '设备管理',
        }
      },
      {
        path: '/user-data',
        name: 'UserData',
        component: () => import('@/views/UserData/user-data.vue'),
        meta: {
          title: '用户健康数据',
        }
      },
      {
        path: '/unusual-warn',
        name: 'UnusualWarn',
        component: () => import('@/views/UnusualWarn/unusual-warn.vue'),
        meta: {
          title: '异常告警',
        }
      },
      {
        path: '/interface-manage',
        name: 'InterfaceManage',
        component: () => import('@/views/InterfaceManage/interface-manage.vue'),
        meta: {
          title: '接口管理',
        }
      },
      {
        path: '/firmware-manage',
        name: 'FirmwareManage',
        component: () => import('@/views/FirmwareManage/firmware-manage.vue'),
        meta: {
          title: '固件管理',
        }
      },
      {
        path: '/firmware-update',
        name: 'FirmwareUpdate',
        component: () => import('@/views/FirmwareUpdate/firmware-update.vue'),
        meta: {
          title: '固件升级',
        }
      },
      {
        path: '/account-manage',
        name: 'AccountManage',
        component: () => import('@/views/AccountManage/account-manage.vue'),
        meta: {
          title: '账号管理',
        }
      },
      {
        path: '/role-manage',
        name: 'RoleManage',
        component: () => import('@/views/RoleManage/role-manage.vue'),
        meta: {
          title: '角色管理',
        }
      },
    ]
  },
  {
    path: '/:pathMatch(.*)',
    redirect: {
      name: 'Dashboard'
    }
  }
]

export default routes
